<template>
  <div>
    <div class="breadcrumb" :gutter="24">站点配置</div>
    <div class="config">
      <!-- 基本配置 -->
      <div class="basicConfig">
        <p>基本配置</p>
        <el-form :model="formData" ref="ruleForm" label-width="150px" class="demo-ruleForm" :hide-required-asterisk="true">
          <el-row :gutter="24">
            <el-col :xs="20" :sm="20" :md="20" :lg="20" :xl="20">
              <el-form-item label="会话最大有效时间" prop="effectiveTime" class="spread">
                <el-select v-model="formData.effectiveTime" placeholder="">
                  <el-option v-for="(item,index) in time" :key="index" :label="item.label" :value="item.value"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="20" :sm="20" :md="20" :lg="20" :xl="20">
              <el-form-item label="会话闲置超时" prop="overtime" class="spread">
                <el-select v-model="formData.overtime" placeholder="">
                  <el-option v-for="(item,index) in time" :key="index" :label="item.label" :value="item.value"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="20" :sm="20" :md="20" :lg="20" :xl="20">
              <el-form-item label="密码最短长度" prop="minLength">
                <el-input type="number" v-enterNumber v-model="formData.minLength" placeholder="" clearable></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="20" :sm="20" :md="20" :lg="20" :xl="20">
              <el-form-item label="密码需要这些特性" prop="features">
                <el-checkbox-group v-model="formData.features">
                  <el-checkbox label="大写字母"></el-checkbox>
                  <el-checkbox label="小写字母"></el-checkbox>
                  <el-checkbox label="数字"></el-checkbox>
                  <el-checkbox label="特殊字段"></el-checkbox>
                </el-checkbox-group>
              </el-form-item>
            </el-col>
            <el-col :xs="20" :sm="20" :md="20" :lg="20" :xl="20">
              <el-form-item>
                <el-button @click="handleReset('ruleForm')">重 置</el-button>
                <el-button type="primary">{{ $t("common.preservation") }}</el-button>
              </el-form-item>
            </el-col>

          </el-row>
        </el-form>
      </div>

      <!-- 数据库配置 -->
      <div class="databaseConfig">
        <p>数据库配置</p>
        <el-form :model="ruleForm" ref="ruleForm1" label-width="150px" class="demo-ruleForm" :hide-required-asterisk="true">
          <el-row :gutter="24">
            <el-col :xs="20" :sm="20" :md="20" :lg="20" :xl="20">
              <el-form-item label="数据库" prop="database" class="spread">
                <el-input v-model="ruleForm.database"></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="20" :sm="20" :md="20" :lg="20" :xl="20">
              <el-form-item label="账户" prop="userName" class="spread">
                <el-input v-model="ruleForm.userName"></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="20" :sm="20" :md="20" :lg="20" :xl="20">
              <el-form-item label="密码" prop="password" class="spread">
                <div style="display:flex">
                  <el-input v-model="ruleForm.password" type="password"></el-input>
                  <el-button type="primary" size="small" style="margin-left:15px">测 试</el-button>
                </div>
              </el-form-item>
            </el-col>
            <el-col :xs="20" :sm="20" :md="20" :lg="20" :xl="20">
              <el-form-item label="Auth Keys" prop="authKeys" class="spread">
                <el-input v-model="ruleForm.authKeys" type="text"></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="20" :sm="20" :md="20" :lg="20" :xl="20">
              <el-form-item label="Auth value" prop="authValue" class="spread">
                <div style="display:flex">
                  <el-input v-model="ruleForm.authValue"></el-input>
                  <el-button type="primary" size="small" style="margin-left:15px">测 试</el-button>
                </div>
              </el-form-item>
            </el-col>
            <el-col :xs="20" :sm="20" :md="20" :lg="20" :xl="20">
              <el-form-item label="Redis Host" prop="redisHost" class="spread">
                <el-input v-model="ruleForm.redisHost" type="text"></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="20" :sm="20" :md="20" :lg="20" :xl="20">
              <el-form-item label="Redis Port" prop="redisPort" class="spread">
                <el-input v-model="ruleForm.redisPort" type="text"></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="20" :sm="20" :md="20" :lg="20" :xl="20">
              <el-form-item label="Redis Auth" prop="redisAuth" class="spread">
                <div style="display:flex">
                  <el-input v-model="ruleForm.redisAuth"></el-input>
                  <el-button type="primary" size="small" style="margin-left:15px">测 试</el-button>
                </div>
              </el-form-item>
            </el-col>
            <el-col :xs="20" :sm="20" :md="20" :lg="20" :xl="20">
              <el-form-item>
                <el-button @click="handleReset1('ruleForm1')">重 置</el-button>
                <el-button type="primary">{{ $t("common.preservation") }}</el-button>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>

    </div>
  </div>

</template>

<script>
export default {
  data () {
    return {
      formData: {
        effectiveTime: '',
        overtime: '',
        minLength: '',
        features: []
      },
      ruleForm: {
        database: '',
        userName: '',
        password: '',
        authKeys: '',
        authValue: '',
        redisHost: '',
        redisPort: '',
        redisAuth: '',
      },
      time: [{
        label: "禁用",
        value: 1
      }]
    }
  },
  created () {

  },
  methods: {
    handleReset (formName) {
      this.$refs[formName].resetFields();
    },
    handleReset1 (formName) {
      this.$refs[formName].resetFields();
    }
  }
}
</script>

<style scoped>
.config {
  display: flex;
}
.basicConfig {
  flex: 1;
  height: calc(100vh - 125px);
  overflow-y: scroll;
  overflow-x: hidden;
}
.databaseConfig {
  flex: 1;
  margin-left: 30px;
}
.spread >>> .el-select {
  width: 100%;
}
.basicConfig >>> .el-col,
.databaseConfig >>> .el-col {
  margin-top: 15px;
}
</style>